home *** CD-ROM | disk | FTP | other *** search
- /*
- * astfio.c ATARI ST kermit file i/o operations
- */
-
- #include <osbind.h> /* TOS bindings */
- #include <stdio.h> /* common I/O defs */
- #include "astinc.h" /* common ST KERMIT defs */
-
- extern FILE *fopen();
- extern FILE *fopenb();
- extern char *strcpy();
- extern char *strcat();
- extern char *rindex();
- extern char *index();
-
-
- /*
- * Global Variables
- */
-
- struct dta_struct {
- char resv[21];
- char attrib;
- int ctim;
- int cdat;
- int lbfsize;
- int hbfsize;
- char fname[14];
- };
-
- struct dta_struct dta;
-
-
- /*
- * file selection functions
- */
-
- fremnode(path)
- char path[];
- /* remove last node (i.e. actual filename) in path spec */
- {char *bsptr;
- bsptr = rindex(path,'\\');
- if ((bsptr == NIL) || (bsptr == &path[2]))
- {
- path[2] = '\\';
- path[3] = '\0';
- }
- else
- *bsptr = '\0';
- }
-
- faddnode(path,node)
- char *path, *node;
- /* add name to path spec, which is terminated by a '\' */
- {
- if (path[3] != '\0') strcat(path,"\\");
- strcat(path,node);
- }
-
-
- fgetpath(path)
- char path[];
- /* get current path */
- {
- Dgetpath(&path[2],0);
- path[0] = Dgetdrv() + 'A';
- path[1] = ':';
- if (path[2] == '\0') strcat(path,"\\");
- }
-
- fsetpath(path)
- char path[];
- {
- Dsetdrv(path[0]-'A');
- Dsetpath(&path[2]);
- }
-
- int fgetfilename(path,name,newfullname)
- char path[], name[], newfullname[];
- /* request filename from user */
- /* full file name will be delivered on newfullname */
- /* path and name are'nt changed */
- /* on abort return FALSE else TRUE */
- {
- int button;
- char tname[PFILNAMLEN];
- strcpy(newfullname,path);
- faddnode(newfullname,"*.*");
- strcpy(tname,name);
- fsel_input(newfullname,tname,&button);
- fremnode(newfullname);
- faddnode(newfullname,tname);
- return button;
- }
-
- int fsetfilename(path,name)
- /* ask user for new filename */
- /* result will be delivered on path and name */
- /* also the path will be changed !*/
- /* and the DTA will be set! */
- /* on abort FALSE will be returned */
- char path[],name[];
- {int button;
- faddnode(path,"*.*");
- fsel_input(path,name,&button);
- fremnode(path);
- fsetpath(path);
- if (button)
- Fsetdta(&dta);
- return button;
- }
-
- /*
- * get first file that match
- */
- int f1stfil(name)
- char name[];
- {
- if (Fsfirst(name,0) != 0)
- return FALSE;
- strcpy(filnam,dta.fname);
- return TRUE;
- }
-
- /*
- * get next file name
- */
- int fnxtfil()
- {
- if (Fsnext() != 0)
- return FALSE;
- strcpy(filnam,dta.fname);
- return TRUE;
- }